﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ImapX.Parsing.Tokens
{
    public class Address : Token
    {
        private NString _name = new NString();
        private NString _adl = new NString();
        private NString _mailbox = new NString();
        private NString _host = new NString();

        // This is required to use Address in NList<T> - why isn't this implied?
        public Address(): this(true) {}

        public Address(bool canBeNIL = true) : base(canBeNIL)
        {
            SetParts(_name, _adl, _mailbox, _host);
        }

        public string Name { get { return _name.Value; } }
        public string ADL { get { return _adl.Value; } }
        public string Mailbox { get { return _mailbox.Value; } }
        public string Host { get { return _host.Value; } }

        public string Email { get { return "\"" + Name + "\" " + "<" + Mailbox + "@" + Host + ">"; } }

        override public string ToString()
        {
            return Email;
        }
    }
}
